#ifndef _W25QXX_H_
#define _W25QXX_H_
#include "spi.h"
#include "system.h"
/*FLASH常用命令*/
#define W25X_WriteEnable 0x06
#define W25X_WriteDisable 0x04
#define W25X_ReadStatusReg 0x05
#define W25X_WriteStatusReg 0x01
#define W25X_ReadData 0x03
#define W25X_FastReadData 0x0B
#define W25X_FastReadDual 0x3B
#define W25X_PageProgram 0x02
#define W25X_BlockErase 0xD8
#define W25X_SectorErase 0x20
#define W25X_ChipErase 0xC7
#define W25X_PowerDown 0xB9
#define W25X_ReleasePowerDown 0xAB
#define W25X_DeviceID 0xAB
#define W25X_ManufactDeviceID 0x90
#define W25X_JedecDeviceID 0x9F
/*其它*/
#define sFLASH_ID 0XEF4017
#define Dummy_Byte 0xFF
#if ELECT
void SPI_FLASH_ReadID(uint8_t *MID, uint16_t *DID);
void SPI_FLASH_WriteEnable(void);
void SPI_FLASH_WaitForWriteEnd(void);
void SPI_FLASH_SectorErase(u32 SectorAddr);
void SPI_FLASH_PageWrite(u8 *pBuffer, u32 WriteAddr, u16 NumByteToWrite);
void SPI_FLASH_BufferWrite(u8 *pBuffer, u32 WriteAddr, u16 NumByteToWrite);
void SPI_FLASH_BufferRead(u8 *pBuffer, u32 ReadAddr, u16 NumByteToRead);
void w25_test();
#endif
typedef void (*pSpiFlashReadId)(u8*, u16 *);
typedef void (*pSpiFlashWriteEnable)(void);
typedef void (*pSpiFlashWaitForWriteEnd)(void);
typedef void (*pSpiFlashSectorErase)(u32);
typedef void (*pSpiFlashPageWrite)(u8 *, u32, u16);
typedef void (*pSpiFlashBufferWrite)(u8 *, u32, u16);
typedef void (*pSpiFlashBufferRead)(u8 *, u32, u16);
typedef struct
{
    pSpiFlashReadId PspiFlashReadId;
    pSpiFlashSectorErase PspiFlashSectorErase;
    pSpiFlashPageWrite PspiFlashPageWrite;
    pSpiFlashBufferWrite PspiFlashBufferWrite;
    pSpiFlashBufferRead PspiFlashBufferRead;
} w25qxx_t;
w25qxx_t *w25qxxCreate(void);
#endif
